package com.tomecode.rvr.generator.util;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Utilities for report generator
 * 
 * @author Frastia Tomas
 * 
 */
public final class Utilities {

	/**
	 * simple date formate
	 */
	private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH.mm.ss");

	private Utilities() {

	}

	/**
	 * check, whether value is empty
	 * 
	 * @param value
	 * @return
	 */
	public static final boolean isEmpty(String value) {
		return (value == null || value.trim().length() == 0);
	}

	/**
	 * formate date
	 * 
	 * @param date
	 *            if is null then return <b>unknow</b>
	 * @return
	 */
	public static final String formateDate(Date date) {
		if (date == null) {
			return "unknow";
		}
		return DATE_FORMAT.format(date);
	}

	/**
	 * create empty string with current length
	 * 
	 * @param length
	 * @return
	 */
	public static final String createEmptyString(int length) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i <= length; i++) {
			sb.append(" ");
		}
		return sb.toString();
	}
}
